#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
#include "LED.h"


static int led_delay=100;

void WWDG_task(void *data);
void LED_task (void *data);
void UART_task(void *data);


void WWDG_task(void *data)
{
	data=data;
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);
    WWDG_SetPrescaler(WWDG_Prescaler_8);
    WWDG_SetWindowValue(80);
    WWDG_Enable(127); //58ms
	for(;;)
	{
	   vTaskDelay( 45 / portTICK_RATE_MS );
	   WWDG_SetCounter(127);
	}
 
}
void LED_task(void *data)
{
	data = data;
    for(;;)
	{
	 LED(Off);
	 vTaskDelay( led_delay / portTICK_RATE_MS );
     LED(On);
     vTaskDelay( 50 / portTICK_RATE_MS );		
    }
	
}

void UART_task(void *data)
{
	data = data;
    for(;;)
	{

	 vTaskDelay(1000 / portTICK_RATE_MS );

    }
	
}

int main(void)
{
//   NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);
  GPIO_LED_INIT();
  LED(On);
  led_delay = 500;
  xTaskCreate(WWDG_task, "WWDG_Task", configMINIMAL_STACK_SIZE, NULL,
              (tskIDLE_PRIORITY + 1), NULL);
  xTaskCreate(LED_task, "Task2", configMINIMAL_STACK_SIZE, NULL,
              (tskIDLE_PRIORITY + 1), NULL);
  LED(Off);
  vTaskStartScheduler();
  return 0;
}



